package com.sk.bilibili.generate.info;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 邵康
 * @date 2021/11/22 18:28
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FieldInfo {

    private String name;
    private String extension;//有扩展名才是文件对象
    private String javaType;
    private Boolean primaryKey;
    private Boolean fill;
    private Boolean file;

    public FieldInfo(String name, String extension, String javaType) {
        this.name =  convert(name);
        this.extension = extension;
        this.javaType = javaType;
        file=!extension.equals("");
    }

    private String convert(String name) {
        String[] items = name.split("_");
        StringBuilder builder=new StringBuilder(items[0]);
        for (int i = 1; i < items.length; i++) {
            builder.append(items[i].substring(0,1).toUpperCase()).append(items[i].substring(1));
        }
        return builder.toString();
    }

}


























